package com.motorola.dp.jenkinsmonitor.dao.specifications;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.springframework.data.jpa.domain.Specification;

import com.motorola.dp.jenkinsmonitor.model.util.svn.SvnModule;

public final class SvnModuleSpecifications {

    private SvnModuleSpecifications() {
        super();
    }

    public static Specification<SvnModule> isNew() {
        return new Specification<SvnModule>() {
            public Predicate toPredicate(Root<SvnModule> module, CriteriaQuery<?> q, CriteriaBuilder cb) {
                return cb.isNull(module.get("id"));
            }
        };
    }

    public static Specification<SvnModule> isNotNew() {
        return new Specification<SvnModule>() {
            public Predicate toPredicate(Root<SvnModule> module, CriteriaQuery<?> q, CriteriaBuilder cb) {
                return cb.isNotNull(module.get("id"));
            }
        };
    }

}
